package cn.sciento.boot.data.change.parse;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.ibatis.mapping.SqlCommandType;

public class ParserFactory {
  private static ParserFactory factory = new ParserFactory();
  
  private static Map<String, DataParser> parseMap = new ConcurrentHashMap<>();
  
  static {
    parseMap.put(SqlCommandType.UPDATE.name(), new UpdateDataParser());
    parseMap.put(SqlCommandType.INSERT.name(), new InsertDataParser());
    parseMap.put(SqlCommandType.DELETE.name(), new DeleteDataParser());
  }
  
  public static ParserFactory getInstance() {
    return factory;
  }
  
  public DataParser creator(SqlCommandType sqlCommandType) {
    return parseMap.get(sqlCommandType.name());
  }
}
